<?php

/** 
* 
* 
* by:南宁火蝶科技有限公司 http:///www.HdsysCms.com
* 声明:本系统禁止用二次开发、侵犯HdsysCms著作和除去HdsysCms进行售卖,如发现将追究一切权利,模版制作属于自己所得可以通过本系统对外开发模版获取收益!
* 
* 2019年第一版本发布 - 到2023.9.1开源使用! 
* php混淆工具:phpencry.wbox.top
* 
* 注意防骗:@HdsysCms 官方没授权任何个人机构合作,唯一收款抬头:《南宁火蝶科技有限公司》和官网显示客服唯一渠道客服,其它渠道以HdsysCms名义行为均骗子!
*
*/
	

defined('HDSYS_SET') or die("".'Not,This File Not Can in Ie Open');
class mysql
{
public $param_intelligence_pdo;
public $param_sql;
public $param_intelligence_rc;
public function __construct()
{
$this->intelligence_connect();
}
public function intelligence_connect()
{
try {
$this->intelligence_pdo=new PDO("mysql:host=".DBHOST.";dbname=".DBTABLE.";", DBUSER, DBPASS,array(PDO::ATTR_PERSISTENT=> true) );
$this->intelligence_pdo->exec("set names utf8;");
} catch (PDOException $e) {
header("Content-Type: text/html;charset=utf-8");
exit(bs_lib::Alerts('Mysql数据库连接失败:',"失败信息:" . $e->getMessage()));
}
}
public function __destruct()
{
}
public function intelligence_sql()
{
return $this->intelligence_sql;
}
public function intelligence_getinsert_id()
{
return $this->intelligence_pdo->lastInsertId();
}
public function HDSYS_my_query($param_sql)
{
$this->intelligence_sql=$param_sql;
$this->intelligence_rc=$this->intelligence_pdo->query($param_sql);
if ($this->intelligence_rc) {
return $this->intelligence_rc;
} else {
mysql::intelligence_SQLaddlog($param_sql);
return false;
}
}
public function get_server_info()
{
return mysqli_get_server_info($this->conn);
}
public function intelligence_query($param_sql)
{
$param_sql=
call_my_str_replace(
'hdsys_',
DBQIANHUAN,
$param_sql);
$this->intelligence_sql=$param_sql;
$PDOStatement=$this->intelligence_pdo->query($param_sql);
if (is_object($PDOStatement)) {
return $PDOStatement;
} else {
mysql::intelligence_SQLaddlog($param_sql);
return false;
}
}
public function intelligence_exec($param_sql)
{
$this->intelligence_connect();
$param_int=$this->intelligence_pdo->exec($$param_sql);
return $param_int;
}
public function intelligence_SQLaddlog($param_sql)
{
$param_name=HDSYS_DIR_SYS . 'Data/log/mysql_db.php';
if (@file_exists($param_name)) {
} else {
@file_put_contents($param_name, '<?php exit; ?>');
}
$param_handle=@fopen($param_name, 'a');
if (!$param_handle) {
return false;
}
if (@fwrite($param_handle, "<?php exit; ?>\n" . $param_sql  . "\n")===false) {
return false;
}
@fclose($param_handle);
return true;
}
public function intelligence_rc_rows($param_PDOStatement)
{
return $this->intelligence_rows($param_PDOStatement);
}
public function intelligence_rows($param_PDOStatement)
{
if (is_object($param_PDOStatement)) {
$param_rows=$param_PDOStatement->rowcount();
return $param_rows;
} else {
return call_my_int_0();
}
}
public function intelligence_array($param_sql)
{
$param_PDOStatement=$this->intelligence_query($param_sql);
if (is_object($param_PDOStatement)) {
$param_array=$param_PDOStatement->fetch(PDO::FETCH_ASSOC);
return $param_array;
}
return false;
}
public function intelligence_fetch($param_sth)
{
$param_data=$param_sth->fetch(PDO::FETCH_ASSOC);
return $param_data;
}
public function intelligence_is_table($param_table)
{
$param_sql="SELECT table_name FROM information_schema.TABLES WHERE table_name='{$param_table}'";
$param_PDOStatement=$this->intelligence_query($param_sql);
if (is_object($param_PDOStatement)) {
$param_array=$param_PDOStatement->fetch(PDO::FETCH_ASSOC);
if($param_array){
return true;
}
}
return false;
}
}
